//
//  ZWLHeaderView.swift
//  testSnap
//
//  Created by czh on 2016/10/11.
//  Copyright © 2016年 zwl. All rights reserved.
//

import UIKit
import SnapKit

private let KMargin : CGFloat = 15
private let KSmallImageW : CGFloat = 80

class ZWLHeaderView: UIView {
    
    fileprivate lazy var bigImageView : UIImageView = {
        let bigImageView = UIImageView()
        bigImageView.backgroundColor = UIColor.red
        return bigImageView
    }()
    
    fileprivate lazy var smallImageView : UIImageView = {
        let smallImageView = UIImageView()
        smallImageView.backgroundColor = UIColor.blue
        return smallImageView
    }()
    
    fileprivate lazy var myLabel : UILabel = {
        let myLabel = UILabel()
        myLabel.text = "拿着斧头打天下"
        myLabel.textColor = UIColor.white
        myLabel.font = UIFont.systemFont(ofSize: 18)
        return myLabel
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
        
        setupCons()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}

extension ZWLHeaderView {
    
    
    fileprivate func setupUI() {
        backgroundColor = UIColor.white
        addSubview(bigImageView)
        addSubview(smallImageView)
        addSubview(myLabel)
        
    }
    
    fileprivate func setupCons() {
        
        bigImageView.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.bottom.equalTo(-KMargin * 2)
        }
        
        smallImageView.snp.makeConstraints { (make) in
            make.width.height.equalTo(KSmallImageW)
            make.right.equalTo(-KMargin)
            make.bottom.equalToSuperview()
        }
        
        myLabel.snp.makeConstraints { (make) in
            make.bottom.equalTo(-KMargin * 2)
            make.right.equalTo(smallImageView).offset(-KSmallImageW-KMargin)
        }
        
    }
}
